from django.db import models

class Property(models.Model):
    region      = models.CharField(max_length=255)
    address     = models.CharField(max_length=255)
    capacity    = models.CharField(max_length=255) 
    description = models.TextField()

    def __unicode__(self):
        return "%s - %s" % (self.region, self.address)

class Picture(models.Model):
    property   = models.ForeignKey(Property)
    image      = models.ImageField(upload_to="images")

OFFER_STATUS_CHOICES = (
    ('pending', 'Pending'),
    ('published', 'Published'),
    ('completed', 'Completed'),
)

class Offer(models.Model):
    property    = models.ForeignKey(Property)
    date_start  = models.DateField()
    date_end    = models.DateField()
    price       = models.DecimalField(max_digits=9, decimal_places=2)
    status      = models.CharField(max_length=20, choices=OFFER_STATUS_CHOICES)

    def __unicode__(self):
        return "%s - (%s - %s) - %d (%s)" % (self.property, self.date_start, self.date_end, self.price, self.status)

RESERVATION_STATUS_CHOICES = (
    ('checked', 'Checked'),
    ('booked', 'Booked'),
    ('canceled', 'Canceled'),
)

class Reservation(models.Model):
    offer       = models.ForeignKey('Offer')
    cancel_date = models.DateField()
    status      = models.CharField(max_length=20, choices=RESERVATION_STATUS_CHOICES)
